class Solution(object):
    def maxProfit(self, prices):
        """
        :type prices: List[int]
        :rtype: int
        """
        minPrice = float('inf')
        maxProfile = 0
        for price in prices:
            minPrice = min(price, minPrice)
            maxProfile = max(maxProfile, price-minPrice)

        return maxProfile

print(Solution().maxProfit([7,1,5,3,6,4]))